package jtk.project4.fleet.field;

import java.text.SimpleDateFormat;

import jtk.project4.fleet.domain.Invoice;
import nl.coderight.jazz.form.FormLayout;
import nl.coderight.jazz.form.FormLayout.Resize;
import nl.coderight.jazz.form.control.CalendarControl;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.ComboField;
import nl.coderight.jazz.form.field.NumberField;
import nl.coderight.jazz.form.field.TextField;

public class InvoiceDetailField extends GroupControl<String>{
	private TextField notesField;
	private TextField poField;
	private ComboField<String> woField;
	private ComboField<String> termsField;
	private ComboField<String> billtoField;
	private NumberField invoField;
	private CalendarControl invoiceDateField ;
	private CalendarControl paydueDateField ;
	private NumberField woamountField;
	private NumberField miscField;
	private NumberField itotalField;
	private NumberField preceivedField;
	
	
	public InvoiceDetailField(String bindID){
		setBindID(bindID);
		createFields();
		createLayout();
	}

	private void createFields() {
		// TODO Auto-generated method stub
		
		notesField = new TextField("notes", 20);
		
		poField = new TextField("po", 15);;
		
		woField = new ComboField<String>("invoices","wo");
		
		termsField = new ComboField<String>("invoices","terms");
		
		billtoField = new ComboField<String>("invoices","billto");
		
		invoField = new NumberField("invo", 15);
		
		invoiceDateField = new CalendarControl("hireDate", 20);
		invoiceDateField.setFormat(new SimpleDateFormat());
		invoiceDateField.showYearSpinner(true);
		invoiceDateField.setPreferredSize(notesField.getPreferredSize());
		
		paydueDateField = new CalendarControl("payduedate", 20);
		paydueDateField.setFormat(new SimpleDateFormat());
		paydueDateField.showYearSpinner(true);
		paydueDateField.setPreferredSize(notesField.getPreferredSize());
		
		woamountField = new NumberField("woamount", 15);
		
		miscField = new NumberField("misc", 15);
		
		itotalField = new NumberField("itotal", 15);
		
		preceivedField = new NumberField("preceived", 15);
	}
	
	private void createLayout() {
		// TODO Auto-generated method stub
		setLayout(new FormLayout())
		.addLabel("Invoice Date")		.addField(invoiceDateField, Resize.HORIZONTAL)
		.addLabel("Notes")			.addField(notesField)
		.addRow()
		.addLabel("Invoices#")		.addField(invoField)
		.addRow()
		.addLabel("WO#")			.addField(woField, Resize.HORIZONTAL)
		.addRow()
		.addLabel("Terms")			.addField(termsField, Resize.HORIZONTAL)
		.addLabel("WO Amount")		.addField(woamountField)
		.addRow()
		.addLabel("Pay Due Date")		.addField(paydueDateField, Resize.HORIZONTAL)
		.addLabel("Misc. Items")		.addField(miscField)
		.addRow()
		.addLabel("PO#")				.addField(poField)
		.addLabel("Invoice Total")		.addField(itotalField)
		.addRow()
		.addLabel("Bill To")			.addField(billtoField, Resize.HORIZONTAL)
		.addLabel("Payment Received")		.addField(preceivedField)
		;	
	}
	
}
